<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>请命名~</title>
	</head>
	<body>
		<input type="text" placeholder="数值" id="number"/>
		<button id="bun">计算</button>
		<script>
		var input = document.getElementById("number");
		document.getElementById("bun").onclick = function(){
			var number = input.value;
			
			// 创建一个Worker对象。其中参数是一个js文件名路径名
			var worker = new Worker("worker.js");
			// 绑定接受消息的监听
			worker.onmessage = function (event){
				console.log("主线程接收分线程返回的数据：", event.data)
				
			}
			// 向分线程发送信息
			worker.postMessage(number);
			console.log("主线程向分线程发送的数据：", number)
		}
		</script>
	</body>
</html>
